<?php

declare(strict_types=1);

namespace JfbQueue;

use JfbQueue\Driver\DriverInterface;
use Hyperf\Context\ApplicationContext;
use Hyperf\Contract\ConfigInterface;
use Hyperf\Process\Annotation\Process;
use Hyperf\Process\ProcessManager;
use Hyperf\Redis\RedisFactory;
use Hyperfx\Framework\Exception\AppException;
use Hyperfx\Framework\Logger\Logx;
use Hyperfx\Utils\AppEnvUtil;
use Hyperfx\Utils\RunModeUtil;
use Psr\Container\ContainerInterface;
use Hyperf\Process\AbstractProcess;


class JobXFactory  {

    protected array $config;

    private $map = [];

    private DriverFactory $driver;
    
    public function __construct(ContainerInterface $container)
    {
        $this->driver = ApplicationContext::getContainer()->get(DriverFactory::class);
    }

    public function get(string $queue = 'default'): JobX
    {
        if (!isset($this->map[$queue])) {
            $driver = $this->driver->get($queue);
            $this->map[$queue] = new JobX($driver);
        }
        return $this->map[$queue];
    }
}